<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">


      <el-form-item label="" prop="beginTime">
        <el-date-picker clearable
                        v-model="queryParams.beginTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="开始日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item  prop="endTimee">
        <el-date-picker clearable
                        v-model="queryParams.endTimee"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="结束日期">
        </el-date-picker>
      </el-form-item>



      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <el-form-item  prop="companyName">
        <el-input
          v-model="queryParams.all"
          placeholder="请输入搜索内容"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="medium" @click="handleQuery">查询</el-button>
        &nbsp;&nbsp;&nbsp;
        <el-button icon="el-icon-refresh" size="medium" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>


    <el-row :gutter="10" class="mb8">

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

<!--    显示页面-->
    <el-table v-loading="loading" :data="stationList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" align="center" width="50"/>
      <el-table-column :show-overflow-tooltip="true" label="岗位名称" align="center" prop="stationName" width="110"/>
      <el-table-column label="岗位等级" align="center" prop="jobGrade" width="100"/>
      <el-table-column label="岗位类型" align="center" prop="stationCategory" width="100"/>
      <el-table-column :show-overflow-tooltip="true" label="企业名称" align="center" prop="companyName" width="200"/>
      <el-table-column :show-overflow-tooltip="true" label="项目组" align="center" prop="proName" width="120"/>
      <el-table-column label="待初筛" align="center" width="60" prop="cou0">
        <template slot-scope="scope">
          <span v-if="scope.row.cou0 == null">
           0
          </span>
          <span v-if="scope.row.cou0 != null">
           {{ scope.row.cou0 }}
          </span>
        </template>


      </el-table-column>
      <el-table-column label="待面试" align="center" width="60" prop="cou1">
        <template slot-scope="scope">
          <span v-if="scope.row.cou1 == null">
           0
          </span>
          <span v-if="scope.row.cou1 != null">
           {{ scope.row.cou1 }}
          </span>
        </template>

      </el-table-column>
      <el-table-column label="待入职" align="center" width="60" prop="cou2">
        <template slot-scope="scope">
          <span v-if="scope.row.cou2 == null">
           0
          </span>
          <span v-if="scope.row.cou2 != null">
           {{ scope.row.cou2 }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="待录用" align="center" width="60" prop="cou2">
        <template slot-scope="scope">
          <span v-if="scope.row.cou3 == null">
           0
          </span>
          <span v-if="scope.row.cou3 != null">
           {{ scope.row.cou3 }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="已入职" align="center" width="60" prop="cou3">
        <template slot-scope="scope">
          <span v-if="scope.row.cou6 == null">
           0
          </span>
          <span v-if="scope.row.cou6 != null">
           {{ scope.row.cou6 }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="薪资范围" align="center" prop="startMoney" width="100">
        <template slot-scope="scope">
          {{ scope.row.startMoney + '~' + scope.row.endMoney }} K
        </template>
      </el-table-column>

      <el-table-column label="岗位定价(K)" align="center" prop="postPricing" width="100">
        <template slot-scope="scope">
          <span v-if="scope.row.postPricing == null">无</span>
          <span v-if="scope.row.postPricing != null">{{ scope.row.postPricing + 'K' }}</span>
        </template>


      </el-table-column>
      <el-table-column label="负责商务" align="center" prop="createdBy" width="120"/>
      <el-table-column label="招聘人数" align="center" prop="need" width="80"/>
      <el-table-column label="招聘截止" align="center" prop="wokeEndTime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.wokeEndTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>

      <el-table-column label="岗位创建时间" align="center" prop="createTime" width="130">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>


      <el-table-column label="操作" width="200" align="center" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-share"
            @click="playVideo(scope.row.stationId)"
            v-hasPermi="['system:station:query']"
          >岗位详情
          </el-button>


          <el-button
            size="mini"
            type="text"
            icon="el-icon-loading"
            @click="recovery(scope.row)"
            v-hasPermi="['system:station:recovery']"
          >开启
          </el-button>

        </template>


      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" :close-on-click-modal='false' append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="公司名称" prop="companyName">
          <el-input v-model="form.companyName" placeholder="请输入公司名称"/>
        </el-form-item>
        <el-form-item label="岗位名称" prop="stationName">
          <el-input v-model="form.stationName" placeholder="请输入岗位名称"/>
        </el-form-item>


        <el-form-item label="岗位类别" prop="stationCategory">
          <el-select v-model="form.stationCategory" placeholder="请输入岗位类别">
            <el-option label="测试" value="测试" @keyup="handleQuery"></el-option>
            <el-option label="运维" value="运维" @keyup="handleQuery"></el-option>
            <el-option label="前端开发" value="前端开发" @keyup="handleQuery"></el-option>
            <el-option label="后端开发" value="后端开发" @keyup="handleQuery"></el-option>
            <el-option label="人工智能" value="人工智能" @keyup="handleQuery"></el-option>
            <el-option label="大数据开发" value="大数据开发" @keyup="handleQuery"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="职位等级" prop="jobGrade">
          <el-select v-model="form.jobGrade" placeholder="请输入职位等级">
            <el-option label="初级" value="初级" @keyup="handleQuery"></el-option>
            <el-option label="中级" value="中级" @keyup="handleQuery"></el-option>
            <el-option label="高级" value="高级" @keyup="handleQuery"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="工作经验" prop="experience">
          <el-select v-model="form.experience" placeholder="请选择工作经验">
            <el-option label="在校生" value="在校生" @keyup="handleQuery"></el-option>
            <el-option label="应届生" value="应届生" @keyup="handleQuery"></el-option>
            <el-option label="1年以内" value="1年以内" @keyup="handleQuery"></el-option>
            <el-option label="1-3年" value="1-3年" @keyup="handleQuery"></el-option>
            <el-option label="3-5年" value="3-5年" @keyup="handleQuery"></el-option>
            <el-option label="5-10年" value="5-10年" @keyup="handleQuery"></el-option>
            <el-option label="10年以上" value="10年以上" @keyup="handleQuery"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="学历要求" prop="education">
          <el-select v-model="form.education" placeholder="请选择学历">
            <el-option label="初中及以下" value="初中及以下"></el-option>
            <el-option label="中专/中技" value="中专/中技"></el-option>
            <el-option label="高中" value="高中"></el-option>
            <el-option label="大专" value="大专"></el-option>
            <el-option label="本科" value="本科"></el-option>
            <el-option label="硕士" value="硕士"></el-option>
            <el-option label="博士" value="博士"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="招聘人数" prop="need">
          <el-input v-model="form.need" placeholder="请输入需招人数"/>
        </el-form-item>
        <el-form-item label="薪酬范围" prop="salaryRange">
          <el-input v-model="form.salaryRange" placeholder="请输入薪酬范围"/>
        </el-form-item>
        <el-form-item label="职位描述" prop="jobDescription">
          <el-input v-model="form.jobDescription" type="textarea" placeholder="请输入内容"/>
        </el-form-item>

        <el-form-item label="工作地址" prop="wokeAddress">
          <el-input v-model="form.wokeAddress" type="textarea" placeholder="请输入xxx省xxx市"/>
        </el-form-item>
        <el-form-item label="公司电话" prop="companyPhone">
          <el-input v-model="form.companyPhone" placeholder="请输入公司电话"/>
        </el-form-item>
        <el-form-item label="公司邮箱" prop="companyMailbox">
          <el-input v-model="form.companyMailbox" placeholder="请输入公司邮箱"/>
        </el-form-item>
        <el-form-item label="公司待遇" prop="companyWelfare">
          <el-input v-model="form.companyWelfare" type="textarea" placeholder="请输入内容"/>
        </el-form-item>


        <el-form-item label="创建人" prop="createdBy">
          <el-input v-model="form.createdBy" placeholder="请输入创建人"/>
        </el-form-item>
        <el-form-item label="截止时间" prop="endTime">
          <el-date-picker clearable
                          v-model="form.endTime"
                          type="date"
                          value-format="yyyy-MM-dd HH:mm:ss"
                          placeholder="请选择截止时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input v-model="form.remarks" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
      </el-form>


      <div slot="footer" class="dialog-footer">
        <el-button type="primary">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 岗位详情 -->
    <el-dialog :title="title" :visible.sync="videoVisible" width="90%" :close-on-click-modal='false' append-to-body>
      <el-descriptions class="margin-top" :column="4" size="medium" border>
        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              岗位名称
            </center>
          </template>
          <center>
            {{ ItoStation.stationName }}
          </center>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              企业名称
            </center>
          </template>
          <center>
            {{ ItoStation.companyName }}
          </center>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              项目组
            </center>
          </template>
          <center>
            {{ ItoStation.proName }}
          </center>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <center><i class="el-icon-user"></i>
              负责商务
            </center>
          </template>
          <center>{{ ItoStation.createdBy }}</center>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <center><i class="el-icon-user"></i>
              发布日期
            </center>
          </template>
          <center>{{ parseTime(ItoStation.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</center>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              学历要求
            </center>
          </template>
          <center>{{ ItoStation.education }}</center>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              岗位等级
            </center>
          </template>
          <center>
            {{ ItoStation.jobGrade }}
          </center>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <center><i class="el-icon-user"></i>
              用工时长
            </center>
          </template>
          <center>{{ ItoStation.endTime }}</center>
        </el-descriptions-item>


        <el-descriptions-item>
          <template slot="label">
            <center><i class="el-icon-user"></i>
              工资薪酬(K)
            </center>
          </template>
          <center  v-if="ItoStation.interview == 0 ">{{ ItoStation.startMoney }}—{{ ItoStation.endMoney }}K</center>
          <center  v-if="ItoStation.interview == 1 ">面议</center>

        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              招聘人数
            </center>
          </template>
          <center>{{ ItoStation.need }}</center>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <center><i class="el-icon-user"></i>
              招聘截止日期
            </center>
          </template>
          <center>{{ parseTime(ItoStation.wokeEndTime, '{y}-{m}-{d}') }}</center>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              省市区
            </center>
          </template>
          <center>
            {{ ItoStation.province }}
          </center>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              详细地址
            </center>
          </template>
          <center>
            {{ ItoStation.wokeAddress }}
          </center>
        </el-descriptions-item>

      </el-descriptions>

      <el-descriptions class="margin-top" size="medium" direction="vertical" :column="4" border>

        <el-descriptions-item :span="4">
          <template slot="label">
            <i class="el-icon-user"></i>
            岗位职责
          </template>
          <span v-html="ItoStation.jobDescription"></span>
        </el-descriptions-item>


        <el-descriptions-item :span="4">
          <template slot="label">
            <i class="el-icon-user"></i>
            岗位要求
          </template>
          <span v-html="ItoStation.remarks"></span>
        </el-descriptions-item>
      </el-descriptions>
    </el-dialog>
  </div>
</template>

<script>
import {niub,recovery,getStation} from "@/api/system/stations";
import {listStation} from "@/api/system/station";

export default {
  name: "Station",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      stationList: [],

      // 岗位详情
      ItoStation: {
        stationId: null,
        stationName: null,
        stationCategory: null,
        postPricing: null,
        jobGrade: null,
        experience: null,
        jobDescription: null,
        education: null,
        recruited: null,
        need: null,
        companyName: null,
        wokeAddress: null,
        companyPhone: null,
        companyMailbox: null,
        endTime: null,
        salaryRange: null,
        remarks: null,
        companyWelfare: null,
        createTime: null,
        createdBy: null,
        updateTime: null,
        updatedBy: null,
        startMoney:null,
        endMoney:null,
        wokeEndTime: null,
        status: "1",
        isDelete: null
      },
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      videoVisible: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        stationName: null,
        stationCategory: null,
        postPricing: null,
        jobGrade: null,
        experience: null,
        jobDescription: null,
        education: null,
        recruited: null,
        need: null,
        companyName: null,
        wokeAddress: null,
        companyPhone: null,
        companyMailbox: null,
        endTime: null,
        salaryRange: null,
        remarks: null,
        companyWelfare: null,
        createTime: null,
        createdBy: null,
        updateTime: null,
        updatedBy: null,
        wokeEndTime: null,
        status: '1',
        beginTime:null,
        endTimee:null,
        startMoney:null,
        endMoney:null,
        cou2: null,
        cou3: null,
        all:null,
        isDelete: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      niub(this.queryParams).then(response => {
        this.stationList = response.rows;
        this.total = response.total;
      });
      this.loading = false;
    },
    /** 查询【请填写功能名称】列表 */
    /*getList() {
      this.loading = true;
      niub(this.queryParams).then(response => {
        this.stationList = response.rows;
        for (let i = 0; i < this.stationList.length; i++) {
          this.stationList[i].salaryRanges = Math.round(this.stationList[i].salaryRange + (this.stationList[i].salaryRange * 0.1))
        }
        this.total = response.total;
        this.loading = false;
      });
    },*/
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        stationId: null,
        stationName: null,
        stationCategory: null,
        postPricing: null,
        jobGrade: null,
        experience: null,
        jobDescription: null,
        education: null,
        recruited: null,
        need: null,
        companyName: null,
        wokeAddress: null,
        companyPhone: null,
        companyMailbox: null,
        endTime: null,
        salaryRange: null,
        remarks: null,
        companyWelfare: null,
        createTime: null,
        createdBy: null,
        updateTime: null,
        updatedBy: null,
        wokeEndTime: null,
        startMoney:null,
        endMoney:null,
        status: "1",
        isDelete: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams={}
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.stationId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },




    /** 恢复按钮操作 */
    recovery(row) {
      const stationIds = row.stationId || this.ids;
      this.$modal.confirm('是否确认恢复该岗位？').then(function () {
        return recovery(stationIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("恢复成功");
      }).catch(() => {
      });
    },

    /** 详情按钮操作 */
    //点击按钮时,触发弹出效果
    playVideo(stationId) {
      getStation(stationId).then(response => {
        this.ItoStation = response.data;
        this.videoVisible = true
      });
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download('system/station/export', {
        ...this.queryParams
      }, `station_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
